<template>
  <cml-module-item :title="titleText" :titleMore="titleText">
    <a-switch
      size="small"
      :checked="isSoundOpen"
      @change="(v) => (soundServer.isSoundOpen = v)"
    />
    <template v-slot:detail>
      <soundSet></soundSet>
    </template>
  </cml-module-item>
</template>
<script>
import { Switch, Select } from 'ant-design-vue'
import CmlModuleItem from '../cml-module-item'
import { mapState, mapMutations } from 'vuex'
import { soundServer, voiceFeedbackServer } from 'anov-core'
import soundSet from './soundSet'

export default {
  name: 'Sound',
  components: {
    ASwitch: Switch,
    CmlModuleItem,
    soundSet
  },
  model: {},
  props: {},
  data() {
    return {
      soundServer,
      voiceFeedbackServer
    }
  },
  watch: {
    isSoundOpen(v) {
      if (v) {
        voiceFeedbackServer.speak('平台音效已开启')
        app.msg({ type: 'info', content: '平台音效已开启' })
      } else {
        voiceFeedbackServer.speak('平台音效已关闭')
        app.msg({ type: 'info', content: '平台音效已关闭' })
      }
    }
  },
  computed: {
    ...mapState('sound', ['isSoundOpen']),
    titleText() {
      return this.$t('cmlpanel.platformSound')
    }
  },
  created() {},
  mounted() {},
  beforeDestroy() {},
  methods: {}
}
</script>
<style lang="scss" scoped></style>
